package com.ruoyi.system.controller;


import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.system.service.MailService;

@RestController
@RequestMapping("/system/email")
public class EmailController {
    @Autowired
    private MailService mailService;

    @PostMapping("/send")
  public AjaxResult sendEmail(@RequestBody Map<String, String> emailData) {
    // 从请求体中获取邮件信息
    String to = emailData.get("to");
    String subject = emailData.get("subject");
    String content = emailData.get("content");

    // 发送邮件的逻辑（根据您的业务实现）
    try {
        mailService.sendSimpleMail(to, subject, content); // 使用您的邮件服务
        return AjaxResult.success("邮件发送成功！");
    } catch (Exception e) {
        return AjaxResult.error("邮件发送失败：" + e.getMessage());
    }
}
}
